import {createRouter, createWebHashHistory} from "vue-router";

const router = createRouter({
    routes: [
        {path: '/', redirect: '/home'},
        {name: 'home', path: '/home', component: ()=>import('./pages/Home.vue'), meta: {title: '主页'},
            children:[
                {path: 'supervision/data', component: ()=>import('./components/supervision/Data.vue'), meta: {title: '公众监督数据列表'}},
                {path: 'supervision/aqi', component: ()=>import('./components/supervision/ConfirmAqi.vue'), meta: {title: '确认AQI数据列表'}},
                {path: 'statistics/province', component: ()=>import('./components/statistics/Province.vue'), meta: {title: '省分组检查统计'}},
                {path: 'statistics/aqi-distribution', component: ()=>import('./components/statistics/AqiDistribution.vue'), meta: {title: 'AQI指数分布统计'}},
                {path: 'statistics/aqi-trend', component: ()=>import('./components/statistics/AqiTrend.vue'), meta: {title: 'AQI指数趋势统计'}},
                {path: 'statistics/other', component: ()=>import('./components/statistics/Other.vue'), meta: {title: '其他数据统计'}},
            ]
        },
        {name: 'login', path: '/login', component: () => import('./pages/Login.vue'), meta: {title: '登录'}}
    ],
    history: createWebHashHistory()
})
const rootTitle = '东软环保公众监督平台管理系统'
router.afterEach((to, next)=>{
    // @ts-ignore
    document.querySelector('title').innerText = rootTitle + '——' +  to.meta.title
})

export default router
